<?php

/*
 * C订单作功能模块
 * 功能：订单
 */

namespace User\Controller;

use Think\C_Controller;

class TestController extends C_Controller {
    
    public function __construct() {
        parent::__construct();
    }
    
    public function index(){
        $argv = "mongodb://";
        if (C("MONGO_USER") != "" && C("MONGO_PWD") != ""){
                $argv .= C("MONGO_USER").":".C("MONGO_PWD")."@";
        }
        $host = C("MONGO_HOST")==""?"127.0.0.1":C("MONGO_HOST");
        if(C("MONGO_PORT") == ""){
            $argv .= $host;
        }else{
            $argv .= "$host:".C("MONGO_PORT");
        }
        $m = new \Mongo($argv);
        $db = $m->selectDB('test');
        $re = $db->foo->find();
        while ($re->hasNext()) {
            $_re[] = (array) $re->getNext();
        }
        var_dump($_re);
    }
}